package com.mqtt.ctwingmqtt.domain.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.persistence.*;
import java.sql.Timestamp;

@Data
@AllArgsConstructor
@NoArgsConstructor
@Entity
@TableName("device_history_data")
@ApiModel(description = "设备历史数据实体类")
public class DeviceHistoryDataEntity {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @ApiModelProperty(value = "主键ID", example = "1")
    @TableId(type = IdType.AUTO)
    private Long id;

    @Column(name = "device_id", nullable = false)
    @ApiModelProperty(value = "设备ID（逻辑外键）", example = "1")
    private Long deviceId;

    @Column(name = "device_code", nullable = false, length = 50)
    @ApiModelProperty(value = "设备编号", example = "D12345")
    private String deviceCode;

    @Column(name = "report_json", nullable = false, columnDefinition = "TEXT")
    @ApiModelProperty(value = "设备上报的JSON数据", example = "{\"key\":\"value\"}")
    private String reportJson;

    @Column(name = "createtime", nullable = false, updatable = false, insertable = false, columnDefinition = "DATETIME DEFAULT CURRENT_TIMESTAMP")
    @ApiModelProperty(value = "创建时间", example = "2023-10-01 12:34:56")
    private Timestamp createTime;

    @Column(name = "updatetime", nullable = false, columnDefinition = "DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP")
    @ApiModelProperty(value = "更新时间", example = "2023-10-01 12:34:56")
    private Timestamp updateTime;
}
